package com.ruitu.mall_98_2.mine;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.beanu.arad.base.my_base.MyBaseActivity;
import com.beanu.arad.widget.progressactivity.ProgressLayout;
import com.ruitu.mall_98_2.R;
import com.ruitu.mall_98_2.mvp.contract.BalanceContract;
import com.ruitu.mall_98_2.mvp.model.BalanceModel;
import com.ruitu.mall_98_2.mvp.presenter.BalancePresenter;
import com.ruitu.router_module.AppHolder;

public class BalanceActivity extends MyBaseActivity<BalancePresenter, BalanceModel> implements BalanceContract.View {

    private TextView tv_balance;
    private TextView tv_withdraw_deposit;
    private TextView tv_check_order;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setHeadTitle("我的余额");
        getBalance();
    }

    public void getBalance() {
        showProgress();
        mPresenter.getBalance(AppHolder.instance().getUser().getAccountId());
    }

    @Override
    protected int getLayoutRes() {
        return R.layout.activity_balance;
    }

    @Override
    protected ProgressLayout findProgressLayout() {
        return null;
    }


    @Override
    public void setData(String balance) {
        tv_balance.setText("￥" + balance);
    }

    @Override
    protected void initViews() {
        super.initViews();
        tv_balance = findViewById(R.id.tv_balance);
        tv_withdraw_deposit = findViewById(R.id.tv_withdraw_deposit);
        tv_check_order = findViewById(R.id.tv_check_order);
        tv_withdraw_deposit.setOnClickListener(this);
        tv_check_order.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        if (tv_withdraw_deposit == v) {
            startActivity(WithdrawDepositActivity.class);
        }

        if (tv_check_order == v){
            startActivity(CheckBillActivity.class);
        }
    }
}
